<%= app_name %>.DateFormat =

  relativeDate: (olderDate, newerDate) ->
    olderDate = new Date(olderDate) if (typeof olderDate == "string")
    newerDate = new Date(newerDate) if (typeof newerDate == "string")

    milliseconds = newerDate - olderDate

    conversions = [
      ["years", 31518720000]
      ["months", 2626560000]
      ["days", 86400000]
      ["hours", 3600000]
      ["minutes", 60000]
      ["seconds", 1000]
    ]

    for conversion in conversions
      result = Math.floor(milliseconds / conversion[1])
      return result + " " + conversion[0] + " ago" if result >= 2

    return "1 second ago"